Clean deprecated loaddb and get_info
authorJeroen van der Heijden <jeroen@transceptor.technology>
Thu, 16 Aug 2018 12:09:50 +0000 (14:09 +0200)
committerJeroen van der Heijden <jeroen@transceptor.technology>
Thu, 16 Aug 2018 12:09:50 +0000 (14:09 +0200)
ChangeLog-2.0.30
include/siri/net/protocol.h
src/siri/net/clserver.c
src/siri/net/protocol.c

index c7ba1461cddb8f63fdf32a26a8408fae53d58beb..0f50d6c0cbf97e1ef6c2e84b707a6e413ebf612e 100644 (file)
@@ -1 +1,4 @@
-  * SiriDB Server can now compile with gnu89/gnu90 (see issue #101)
\ No newline at end of file
+  * SiriDB Server can now compile with gnu89/gnu90. (see issue #101)
+  
+  * Removed deprecated info- and loaddb requests.
+  
\ No newline at end of file
index c8cd1c41762c8b086af7ccccc3736c52a9603b16..373dfe61341774b22d1303188a06d404ca1b8e8a 100644 (file)
 
 typedef enum
 {
-    CPROTO_REQ_QUERY,                   /* (query, time_precision)          */
-    CPROTO_REQ_INSERT,                  /* series with points map/array     */
-    CPROTO_REQ_AUTH,                    /* (user, password, dbname)         */
-    CPROTO_REQ_PING,                    /* empty                            */
-    CPROTO_REQ_INFO,                    /* empty                            */
-    CPROTO_REQ_LOADDB,                  /* database path                    */
-    CPROTO_REQ_REGISTER_SERVER,         /* (uuid, host, port, pool)         */
+    CPROTO_REQ_QUERY=0,                 /* (query, time_precision)          */
+    CPROTO_REQ_INSERT=1,                /* series with points map/array     */
+    CPROTO_REQ_AUTH=2,                  /* (user, password, dbname)         */
+    CPROTO_REQ_PING=3,                  /* empty                            */
+
+    /* Start internal usage */
+    CPROTO_REQ_REGISTER_SERVER=6,       /* (uuid, host, port, pool)         */
     CPROTO_REQ_FILE_SERVERS,            /* empty                            */
     CPROTO_REQ_FILE_USERS,              /* empty                            */
     CPROTO_REQ_FILE_GROUPS,             /* empty                            */
     CPROTO_REQ_FILE_DATABASE,           /* empty                            */
+    /* End linternal usage */
+
     /* Administrative API request */
     CPROTO_REQ_ADMIN=32,                /* (user, password, request, {...}) */
 } cproto_client_t;
@@ -31,30 +33,28 @@ typedef enum
 typedef enum
 {
     /* success */
-    CPROTO_RES_QUERY,                   /* {query response data}            */
-    CPROTO_RES_INSERT,                  /* {"success_msg": ...}             */
-    CPROTO_RES_AUTH_SUCCESS,            /* empty                            */
-    CPROTO_RES_ACK,                     /* empty                            */
-    CPROTO_RES_INFO,                    /* [version, [dnname1, ...]]        */
-    CPROTO_RES_FILE,                    /* file content                     */
+    CPROTO_RES_QUERY=0,                 /* {query response data}            */
+    CPROTO_RES_INSERT=1,                /* {"success_msg": ...}             */
+    CPROTO_RES_AUTH_SUCCESS=2,          /* empty                            */
+    CPROTO_RES_ACK=3,                   /* empty                            */
+    CPROTO_RES_FILE=5,                  /* file content                     */
 
     /* Administrative API success */
     CPROTO_ACK_ADMIN=32,                /* empty                            */
-    CPROTO_ACK_ADMIN_DATA,              /* [...]                            */
+    CPROTO_ACK_ADMIN_DATA=33,           /* [...]                            */
 
     /* errors 64-69 are errors with messages */
     CPROTO_ERR_MSG=64,                  /* {"error_msg": ...}               */
-    CPROTO_ERR_QUERY,                   /* {"error_msg": ...}               */
-    CPROTO_ERR_INSERT,                  /* {"error_msg": ...}               */
-    CPROTO_ERR_SERVER,                  /* {"error_msg": ...}               */
-    CPROTO_ERR_POOL,                    /* {"error_msg": ...}               */
-    CPROTO_ERR_USER_ACCESS,             /* {"error_msg": ...}               */
-    CPROTO_ERR,                         /* empty (use for unexpected errors)*/
-    CPROTO_ERR_NOT_AUTHENTICATED,       /* empty                            */
-    CPROTO_ERR_AUTH_CREDENTIALS,        /* empty                            */
-    CPROTO_ERR_AUTH_UNKNOWN_DB,         /* empty                            */
-    CPROTO_ERR_LOADING_DB,              /* empty                            */
-    CPROTO_ERR_FILE,                    /* empty                            */
+    CPROTO_ERR_QUERY=65,                /* {"error_msg": ...}               */
+    CPROTO_ERR_INSERT=66,               /* {"error_msg": ...}               */
+    CPROTO_ERR_SERVER=67,               /* {"error_msg": ...}               */
+    CPROTO_ERR_POOL=68,                 /* {"error_msg": ...}               */
+    CPROTO_ERR_USER_ACCESS=69,          /* {"error_msg": ...}               */
+    CPROTO_ERR=70,                      /* empty (use for unexpected errors)*/
+    CPROTO_ERR_NOT_AUTHENTICATED=71,    /* empty                            */
+    CPROTO_ERR_AUTH_CREDENTIALS=72,     /* empty                            */
+    CPROTO_ERR_AUTH_UNKNOWN_DB=73,      /* empty                            */
+    CPROTO_ERR_FILE=75,                 /* empty                            */
 
     /* Administrative API errors */
     CPROTO_ERR_ADMIN=96,                /* {"error_msg": ...}               */
index 8c4e75b8bca1046e94ba5926a0a9cbb8f1621cae..d051aab4365bff68e86acd0a72fe7cf6ddbc2ebb 100644 (file)
@@ -77,8 +77,6 @@ static void on_auth_request(uv_stream_t * client, sirinet_pkg_t * pkg);
 static void on_query(uv_stream_t * client, sirinet_pkg_t * pkg);
 static void on_insert(uv_stream_t * client, sirinet_pkg_t * pkg);
 static void on_ping(uv_stream_t * client, sirinet_pkg_t * pkg);
-static void on_info(uv_stream_t * client, sirinet_pkg_t * pkg);
-static void on_loaddb(uv_stream_t * client, sirinet_pkg_t * pkg);
 static void on_reqfile(
         uv_stream_t * client,
         sirinet_pkg_t * pkg,
@@ -92,7 +90,6 @@ static void CLSERVER_send_server_error(
 static void CLSERVER_send_pool_error(
         uv_stream_t * stream,
         sirinet_pkg_t * pkg);
-static int CLSERVER_on_info_cb(siridb_t * siridb, qp_packer_t * packer);
 static void CLSERVER_on_register_server_response(
         slist_t * promises,
         siridb_server_async_t * server_reg);
@@ -256,12 +253,6 @@ static void on_data(uv_stream_t * client, sirinet_pkg_t * pkg)
         case CPROTO_REQ_PING:
             on_ping(client, pkg);
             break;
-        case CPROTO_REQ_INFO:
-            on_info(client, pkg);
-            break;
-        case CPROTO_REQ_LOADDB:
-            on_loaddb(client, pkg);
-            break;
         case CPROTO_REQ_REGISTER_SERVER:
             on_register_server(client, pkg);
             break;
@@ -577,82 +568,6 @@ static void on_ping(uv_stream_t * client, sirinet_pkg_t * pkg)
     }
 }
 
-static void on_info(uv_stream_t * client, sirinet_pkg_t * pkg)
-{
-    qp_packer_t * packer = sirinet_packer_new(128);
-    if (packer != NULL)
-    {
-        qp_add_type(packer, QP_ARRAY_OPEN);
-        qp_add_string(packer, SIRIDB_VERSION);
-        qp_add_type(packer, QP_ARRAY_OPEN);
-
-        if (!llist_walk(
-                siri.siridb_list,
-                (llist_cb) CLSERVER_on_info_cb,
-                packer))
-        {
-            sirinet_pkg_t * package = sirinet_packer2pkg(
-                    packer,
-                    pkg->pid,
-                    CPROTO_RES_INFO);
-
-            /* ignore result code, signal can be raised */
-            sirinet_pkg_send(client, package);
-        }
-        else
-        {
-            qp_packer_free(packer);
-        }
-    }
-}
-
-/*
- * This function can raise a SIGNAL.
- */
-static void on_loaddb(uv_stream_t * client, sirinet_pkg_t * pkg)
-{
-    qp_unpacker_t unpacker;
-    qp_unpacker_init(&unpacker, pkg->data, pkg->len);
-
-    qp_obj_t qp_dbpath;
-    if (qp_next(&unpacker, &qp_dbpath) == QP_RAW)
-    {
-        char * dbpath = strndup(
-                (const char *) qp_dbpath.via.raw, qp_dbpath.len);
-
-        if (dbpath == NULL)
-        {
-            ERR_ALLOC
-        }
-        else
-        {
-            siridb_t * siridb = siridb_new(dbpath, LOCK_QUIT_IF_EXIST);
-            if (siridb != NULL)
-            {
-                siridb->server->flags |= SERVER_FLAG_RUNNING;
-
-                /* Force one heart-beat */
-                siri_heartbeat_force();
-            }
-            sirinet_pkg_t * package = sirinet_pkg_new(
-                    pkg->pid,
-                    0,
-                    (siridb == NULL) ?
-                            CPROTO_ERR_LOADING_DB : CPROTO_RES_ACK,
-                    NULL);
-            if (package != NULL)
-            {
-                sirinet_pkg_send(client, package);
-            }
-            free(dbpath);
-        }
-    }
-    else
-    {
-        log_error("Incorrect package received: 'on_loaddb'");
-    }
-}
-
 /*
  * This function can raise a SIGNAL.
  */
@@ -916,15 +831,6 @@ static void on_req_admin(uv_stream_t * client, sirinet_pkg_t * pkg)
     }
 }
 
-/*
- * Typedef: llist_cb
- * Returns 0 if successful or -1 and a SIGNAL is raised if not.
- */
-static int CLSERVER_on_info_cb(siridb_t * siridb, qp_packer_t * packer)
-{
-    return qp_add_string(packer, siridb->dbname);
-}
-
 /*
  * Typedef: sirinet_promises_cb
  */
index e71bccb318a67ebd8947e73165d30197f53699f8..401979583bb032babb074c0317d1a061fc00a3c8 100644 (file)
@@ -22,16 +22,14 @@ const char * sirinet_cproto_client_str(cproto_client_t n)
     case CPROTO_REQ_INSERT: return "CPROTO_REQ_INSERT";
     case CPROTO_REQ_AUTH: return "CPROTO_REQ_AUTH";
     case CPROTO_REQ_PING: return "CPROTO_REQ_PING";
-    case CPROTO_REQ_INFO: return "CPROTO_REQ_INFO";
 
-    /* deprecated, used by the old SiriDB manage tool */
-    case CPROTO_REQ_LOADDB: return "CPROTO_REQ_LOADDB";
+    /* start internal usage */
     case CPROTO_REQ_REGISTER_SERVER: return "CPROTO_REQ_REGISTER_SERVER";
     case CPROTO_REQ_FILE_SERVERS: return "CPROTO_REQ_FILE_SERVERS";
     case CPROTO_REQ_FILE_USERS: return "CPROTO_REQ_FILE_USERS";
     case CPROTO_REQ_FILE_GROUPS: return "CPROTO_REQ_FILE_GROUPS";
     case CPROTO_REQ_FILE_DATABASE: return "CPROTO_REQ_FILE_DATABASE";
-    /* end deprecated */
+    /* end internal usage */
 
     case CPROTO_REQ_ADMIN: return "CPROTO_REQ_ADMIN";
 
@@ -49,12 +47,7 @@ const char * sirinet_cproto_server_str(cproto_server_t n)
     case CPROTO_RES_INSERT: return "CPROTO_RES_INSERT";
     case CPROTO_RES_AUTH_SUCCESS: return "CPROTO_RES_AUTH_SUCCESS";
     case CPROTO_RES_ACK: return "CPROTO_RES_ACK";
-
-    /* deprecated, used by the old SiriDB manage tool */
-    case CPROTO_RES_INFO: return "CPROTO_RES_INFO";
     case CPROTO_RES_FILE: return "CPROTO_RES_FILE";
-    /* end deprecated */
-
     case CPROTO_ACK_ADMIN: return "CPROTO_ACK_ADMIN";
     case CPROTO_ACK_ADMIN_DATA: return "CPROTO_ACK_ADMIN_DATA";
     case CPROTO_ERR_MSG: return "CPROTO_ERR_MSG";
@@ -67,11 +60,7 @@ const char * sirinet_cproto_server_str(cproto_server_t n)
     case CPROTO_ERR_NOT_AUTHENTICATED: return "CPROTO_ERR_NOT_AUTHENTICATED";
     case CPROTO_ERR_AUTH_CREDENTIALS: return "CPROTO_ERR_AUTH_CREDENTIALS";
     case CPROTO_ERR_AUTH_UNKNOWN_DB: return "CPROTO_ERR_AUTH_UNKNOWN_DB";
-
-    /* deprecated, used by the old SiriDB manage tool */
-    case CPROTO_ERR_LOADING_DB: return "CPROTO_ERR_LOADING_DB";
     case CPROTO_ERR_FILE: return "CPROTO_ERR_FILE";
-    /* end deprecated */
 
     case CPROTO_ERR_ADMIN: return "CPROTO_ERR_ADMIN";
     case CPROTO_ERR_ADMIN_INVALID_REQUEST: return "CPROTO_ERR_ADMIN_INVALID_REQUEST";